<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>产品质量管理</el-breadcrumb-item>
      <el-breadcrumb-item>不合格品处置</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <div class="sea-box">
        <el-form ref="form" label-width="120px">
          <el-form-item label="产品SFC">
            <el-input placeholder="请输入SFC" v-model="product_sfc"></el-input>
          </el-form-item>
        </el-form>
        <div class="btn">
          <el-button type="success" @click="search">查询</el-button>
        </div>
      </div>
      <div v-show="sfcinfoDV">
        <div class="bigger">
          <div class="lefter">
            <span class="title">产品信息</span>
            <el-form ref="form" label-width="120px" :model="infoList">
              <el-form-item label="产品名称">
                <el-input v-model="infoList.item_name" disabled></el-input>
              </el-form-item>
              <el-form-item label="产品描述">
                <el-input v-model="infoList.item_desc" disabled></el-input>
              </el-form-item>
              <el-form-item label="所属工单">
                <el-input v-model="infoList.shoporderId" disabled></el-input>
              </el-form-item>
              <el-form-item label="异常单位">
                <el-input v-model="infoList.operation" disabled></el-input>
              </el-form-item>
              <el-form-item label="操作人">
                <el-input v-model="infoList.by_user" disabled></el-input>
              </el-form-item>
              <el-form-item label="操作时间">
                <el-input v-model="infoList.create_time" disabled></el-input>
              </el-form-item>
            </el-form>
          </div>
          <div class="middler"></div>
          <div class="righter">
            <div class="info">
              <span class="title">不合格信息</span>
              <el-form ref="form" label-width="120px" :model="infoList">
                <el-form-item label="不合格组">
                  <el-input v-model="infoList.nc_code_group_desc" disabled></el-input>
                </el-form-item>
                <el-form-item label="不合格代码">
                  <el-input v-model="infoList.nc_code_desc" disabled></el-input>
                </el-form-item>
              </el-form>
            </div>
            <div class="way">
              <span class="title">处置方式</span>
              <div class="selebox">
                <div>
                  <el-radio-group v-model="radio">
                    <el-radio label="repair">维修</el-radio>
                  </el-radio-group>
                </div>
                <div>
                  <el-radio-group v-model="radio">
                    <el-radio label="scrap">报废</el-radio>
                  </el-radio-group>
                </div>
              </div>
              <el-form ref="form" label-width="120px">
                <el-form-item label="指定产品跳至哪个操作" label-width="160px">
                  <el-select v-model="chioceOpera" placeholder="请选择工序" >
                    <el-option
                      v-for="item in operationList"
                      :key="item.operation"
                      :label="item.operation"
                      :value="item.operation"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="备注" label-width="160px">
                  <el-input type="textarea" v-model="textarea"></el-input>
                </el-form-item>
              </el-form>
              <el-button type="primary" @click="dispose">处置</el-button>
            </div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      product_sfc: "",
      sfcinfoDV: false,
      radio:'repair',
      infoList: {},
      operationList:[],
      chioceOpera:"",
      textarea:"",
    };
  },
  methods: {
    search() {
      this.$axios({
        headers: {
          "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        },
        method: "post",
        url: "/IE_MES/qc/getNcHandleSFCData.shtml?" + "sfc=" + this.product_sfc,
      }).then((res) => {
        console.log(res.data);
        this.infoList = res.data.ncInfo[0];
        this.operationList = res.data.operationList;
        this.sfcinfoDV = true;
      });
    },
    dispose(){
        this.$axios({
        headers: {
          "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        },
        method: "post",
        url: "/IE_MES/qc/addNcHandleMsg.shtml",
        data: this.$qs.stringify({
              "sfc":this.product_sfc,
              "radio": this.radio,
              "remarks": this.textarea,
              "operation": this.chioceOpera
            }),
      }).then((res) => {
        if(res.data == "{\"content\":null,\"message\":\"\",\"result\":[],\"score\":\"\",\"status\":true}"){
            this.$message({
                type: "success",
                message: "操作成功!",
              });
        }
      });
    }
  },
};
</script>

<style lang="less" scoped>
.sea-box {
  width: 50%;
  height: 100px;
  margin: 0 auto;
  position: relative;
  .btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
}
.title {
  display: block;
  font-weight: 900;
  font-size: 20px;
  margin-bottom: 20px;
  margin-left: 20px;
}
.bigger {
  display: flex;
  margin-top: 20px;
  width: 100%;
}
.lefter {
  width: 42%;
}
.middler {
  width: 10%;
}
.righter {
  display: flex;
  flex-direction: column;
  width: 42%;
}
.info {
  width: 100%;
}
.selebox {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
}
</style>